#ifndef BONETREECRTL_H
#define BONETREECRTL_H

#include <wx/treectrl.h>
#include "../include/Bone.h"

class BoneManager;

class BoneTreeCtrl: public wxTreeCtrl
{
    public:
        BoneTreeCtrl(wxWindow* parent,
                     wxWindowID id,
                     const wxPoint& pos = wxDefaultPosition,
                     const wxSize& size = wxDefaultSize,
                     long style =  wxTR_DEFAULT_STYLE,
                     const wxValidator& validator = wxDefaultValidator,
                     const wxString& name = _("treeCtrl") );
        virtual ~BoneTreeCtrl();

        /** setBoneManager to this tree
        * @param boneManager - poinnter to boneManager
        */
        void setBoneManager(BoneManager* boneManager);

        /** Updating tree by information from boneManager*/
        void rebuild(Bone* rootBone);

        /** Select in tree bone which has selectedJoin set to (0-begin) or (1-end) */
        void updateSelection();

        /** Clear all tree */
        void clear();

        /** Called by on Select event
        * @param evt - selection event
        */
        void itemSelected(wxTreeEvent& evt );

    protected:
    private:

        /** Make selection a specified bone in tree
        * @param bone - bone to select
        */
        void selectBone(Bone* bone);

        /** Finding in tree specified bone
        * @param bone - bone to find
        * @return wxTreeItemId of found bone
        */
        wxTreeItemId findBone(Bone* bone);

        /** BoneManger */
        BoneManager* boneManager;

        /** Root bone of sceleton */
        Bone* rootBone;

        /**  */
        bool selectionByMethodCall;

        DECLARE_EVENT_TABLE()
};

#endif // BONETREECRTL_H
